import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        char[] ch=str.toCharArray();
        for(int i=0;i<ch.length;i++){
            if(ch[i]>=(char)('a'+13)){
                ch[i]=(char)(ch[i]-26);
            }
        }
        Arrays.sort(ch);
        int mid=(ch.length-1)/2;
        int count=0;
        for(int i=0;i<ch.length;i++){
            if(ch[i]<'a'){
                ch[i]=(char)(ch[i]+26);
            }
        }
        for(int i=0;i<ch.length;i++){
            if(ch[i]>=ch[mid]+13){
                count+=26-(ch[i]-ch[mid]);
            }else if(ch[i]>ch[mid]){
                count+=ch[i]-ch[mid];
            }else if(ch[i]<=ch[mid]-13){
                count+=26-(ch[mid]-ch[i]);
            }else{
                count+=ch[mid]-ch[i];
            }
        }
        System.out.println(count);
    }
}